{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='demo/game_common_nav'}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$page_total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="{$do}" />
                <div class="form-group">
                    {if count($themelist)>1}
                    <div class="col-xs-12 col-sm-2 col-md-2">
                        <select onchange="submitForm();" class="form-control" name="themeid">
                            {loop $themelist $row}
                            <option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                    <input type="hidden" name="themeid" value="{$themeid}" />
                    {/if}
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <span class="help-block">温馨提示：问题库数量上限为10个</span>
                    </div>
                </div>
                {if $page_total <10}
                <div class="form-group">
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <a href="{php echo createWebUrlPlugin('demo/index/add',array('themeid'=>$themeid));}" class="btn {if $op == 'box_add'}btn-primary{else}btn-default{/if}">添加问题</a>
                    </div>
                </div>
                {/if}
            </form>
        </div>
    </div>

    <input type="hidden" name="current_ac" id="current_ac" value="{$ac}">
    <!--  列表框  -->
    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 50px">序号</th>
                        <th style="width: 120px">问题描述</th>
                        <th style="width: 120px">选项A</th>
                        <th style="width: 120px">选项B</th>
                        <th style="width: 120px">选项C</th>
                        <th style="width: 100px">正确选项</th>
                        <th style="width: 120px">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $item}
                    <tr>
                        <td>{$item['q_id']}</td>
                        <td>{$item['question']}</td>
                        <td>{$item['first']}</td>
                        <td>{$item['second']}</td>
                        <td>{$item['third']}</td>
                        <td>{php echo formatGameSelect($item['sure_method']);}</td>
                        <td>
                            <a class="btn btn-primary btn-sm" style="width: 35px" onclick="changeOrDelLttInfo(this)"
                               data-type="edit"
                               data-edit-url="{php echo createWebUrlPlugin('demo/edit', array('themeid'=>$themeid,'q_id'=>$item['q_id']));}"
                               data-themeid="{$themeid}" data-id="{$item['q_id']}"  title="修改信息" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil-square-o"> </i></a>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{$pager}
<script type="text/javascript">
    $(document).ready(
        function (){

        }
    );
    function drop_confirm(msg, url){
        if(confirm(msg)){
            window.location = url;
        }
    }
    // 修改、删除
    function changeOrDelLttInfo(e) {
        let type = e.getAttribute("data-type");
        let redirectUrl = e.getAttribute("data-edit-url");
        if (type=='edit'){
            window.location.href = redirectUrl;
        }
    }
</script>
